@extends('Admin.layouts.common')

@section('content')
    <div class="container myContainer">
        <button class="btn btn-info searchBtn" onclick="$('.search_box').slideToggle();">搜索/筛选</button>
        <div class="search_box">
            <form id="search_form" method="GET">
                <label>
                    Ui：<br>
                    <input name="key" type="text" class="form-control search_form_control" value="{{ $_search['uid'] }}">
                </label>
                <label>
                    标题：<br>
                    <input name="key" type="text" class="form-control search_form_control" value="{{ $_search['key'] }}">
                </label>
                
                <button class="btn btn-primary" type="submit">&nbsp;&nbsp;确定&nbsp;&nbsp;</button>
            </form>
        </div>

        <div class="table-responsive">
            <table class="table">
              
                <caption>已拒绝投稿({{$list->total()}})</caption>
             
                <thead>
                    <tr>

                        <th>
                            #
                        <th>Uid</th>
                        <th>标题</th>
                        <th>图片</th>
                        <th>日期</th>
                        <th>在线状态</th>
                        <th>审核状态</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    @forelse($list->items() as $item)
                        <tr id="tr_{{$item->id}}">
                            <td>
                               
                                {{ $item->id }}</td>
                            <td>
                              {{$item->uid}}
                            </td>
                            <td> {{$item->title}}</td>
                            <td>

                                @foreach($item->pic as $img)
                                    <img src="{{$img}}" style="max-width: 200px">
                                @endforeach
                            </td>
                            <td>{{ date('Y-m-d H:i:s',$item->time) }}</td>
                            <td>{{ $status[$item->status] }}</td>
                            <td>{{ $examine[$item->examine] }}<br/>
                                原因：{{ $item->examine_message }}</td>
                            <td>

                              <a href="javascript:;" onclick="shenhe({{$item->id}});">审核</a>

                              <a href="javascript:;" onclick="caozuo({{$item->id}})">操作</a>
                            </td>
                        </tr>
                    @empty
                        <tr><td class="text-center" colspan="7">没有数据</td></tr>
                    @endforelse
                </tbody>
            </table>
            <div class="text-center">
               
                {{ $list->links() }}
            </div>
        </div>

    </div>
@endsection

@section('foot')
<script type="text/javascript">
function ajax_delete_theme(id){
    if(confirm('确认删除吗?')){
        $.post("/theme/ajax_delete_theme/"+id,{},function(json){
            if(json.status==1){
                $("#tr_"+json.data).fadeOut();
            }else{
                alert(json.info);
            }
        },"json");
    }
}
function set_cat(id,obj){
    var type = $(obj).val();
    var name = $(obj).find("option:selected").text();
    $("td#cat_"+id).text(name);
    $.post('/article/ajax_set_cat/'+id,{type:type},function(json){
    
    },"json");
}

function batch_refund(){
    var a = $("input[name='ids[]']:checked").length;
    if(a==0){
        alert("请选择要拒绝的文章");
        return false;
    }
    var ids = "";
    $("input[name='ids[]']:checked").each(function(i){
        if (i == 0) {
            ids = this.value;//循环每个值
        } else {
            ids += "," + this.value;
        }
    });
    if(confirm("您选择了"+a+"个项目，确定要批量拒接吗？")){
        $.post("/article/ajax_batch_refund",{ids:ids},function(json){
            if(json.status==1){
                window.location.reload();
            }else{
                alert("error");
            }
        },"json");
    }
}

function select_all(){
    $('input').iCheck('check');
}
function unall(){
    $('input').iCheck('toggle');
}

function shenhe(id){
    layx.iframe('event-ondestroy','关闭前后控制','/tou/ajax_info/'+id,{
        event:{
            ondestroy:{
                after: function () {
                    window.location.reload();
                }
            }
        }
    });
}

function caozuo(id){
    var dataid = id;
    layx.confirm('操作','点击下方按钮操作 ',null,{
    buttons:[
        @if(in_array($item->status,[0,2]))
        {
            label:'上线',
            callback:function(id, button, event){
               window.location.href="/tou/ajax_update_status/"+dataid+"/?status=1";
            }
        },
        @endif
        @if(in_array($item->status,[1,2]))
        {
            label:'下线',
            callback:function(id, button, event){
                window.location.href="/tou/ajax_update_status/"+dataid+"/?status=0";
            }
        },
        @endif
        @if(in_array($item->status,[0,1]))
        {
            label:'删除',
            callback:function(id, button, event){
                window.location.href="/tou/ajax_update_status/"+dataid+"/?status=2";
            }
        }
        @endif
    ]
});
}
</script>
@endsection